home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / comm / tcp / jl_update.lha / Jl_update.rexx
OS/2 REXX Batch file  |  2000-10-23  |  2KB  |  93 lines

  1. /* Just linux Dyn DNS updater v2
  2. **
  3. **
  4. **    Requriments
  5. **
  6. **    rxsocket installede
  7. **
  8. **
  9. **    (C) 2000 Jacob Dahl Pind aka Rachael/Copy`n`Paste Tech.
  10. **
  11. **    
  12. **
  13. **
  14. */
  15.  
  16.  
  17. /* config space */
  18.  
  19. user="Foobar"
  20. password="FooPassword"
  21.  
  22. /* host */
  23. host="Foobar.penguinpowered.com"
  24.  
  25. /*
  26. **
  27. **    overrideip = 1 for overriding the automatical fetchede ip
  28. **    replace with 0 for using the fetchede ip 
  29. **
  30. **    usefull if your machine is on a lan
  31. **
  32. **
  33. */
  34.  
  35. overrideip="1"
  36. ip="213.237.16.246"
  37.  
  38. /* don`t mess with the code below */
  39.  
  40. defaultserver = "www.justlinux.com"
  41. urlprefix = "/bin/controlpanel/dyndns/jlc.pl?direct=1"
  42.  
  43. call addlib("rxsocket.library",0,-30,0)
  44.  
  45. if ~(overrideip) then do 
  46.     ip=GetHostID()
  47. end
  48.  
  49. if ~Open("STDERR","CONSOLE:","W") then SDTERR="STDOUT"
  50.  
  51. sin.addraddr=resolve(defaultserver)
  52. if sin.addraddr=-1 then call err "host <"host"> not found",1
  53. sin.addrport=80
  54.  
  55. sock=socket("INET","STREAM")
  56. if sock=-1 then call err "can't create socket"
  57. if connect(sock,"SIN")<0 then call err "can't connect"
  58.  
  59. fin="D0A"x
  60. request="GET" space(urlprefix'&username='user'&password='password'&host='host'&ip='ip) "HTTP/1.0"fin
  61. request=request||fin
  62.  
  63. say "sending request..."
  64. if send(sock,request)<0 then call err "error sending"
  65.  
  66. say "receiving results..."
  67. if recvline(sock,"BUF",256)<0 then call err "error receiving"
  68. if buf="" then call err "empty answer",1
  69. parse var buf http code
  70. if word(code,1)~=200 then call err "error from server" code,1
  71.  
  72. say "receiving head..."
  73. do while buf~="D0A"x
  74.     if recvline(sock,"BUF",256)<0 then call err "error receiving"
  75. end
  76.  
  77. say "receiving file..."
  78. res=recv(sock,"BUF",256)
  79. do while res>0
  80.     call writech("STDOUT",buf)
  81.     res=recv(sock,"BUF",256)
  82. end
  83. if res<0 then call err "error receiving"
  84. say "done."
  85. exit
  86.  
  87. /* error handling procedure */
  88. err: Procedure Expose socket
  89. parse arg msg
  90.   If IsLibOn('SOCKET') Then If errno() == 4 Then msg = 'timeout'
  91.   Say 'jldyndns :' msg
  92. Exit
  93.